package com.bw.jetpacktest.navigartion.replace;

import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.navigation.NavHostController;
import androidx.navigation.fragment.NavHostFragment;
import androidx.navigation.ui.NavigationUI;

import com.bw.jetpacktest.R;
import com.google.android.material.bottomnavigation.BottomNavigationView;

public class RelaceActivity extends AppCompatActivity {

    private BottomNavigationView replace_navbottom;
    private NavHostFragment replace_nav_fragment;
    private NavHostController controller;//绑定bottom以及navhostfragment切换

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_replace);
        init();
    }

    private void init(){
        replace_navbottom = findViewById(R.id.replace_navbottom);
        replace_nav_fragment = (NavHostFragment) getSupportFragmentManager()
                .findFragmentById(R.id.replace_nav_fragment);
        controller = (NavHostController) replace_nav_fragment.getNavController();
        controller.setGraph(R.navigation.replace_navigation);
        NavigationUI.setupWithNavController(replace_navbottom,controller);
    }

}
